package com.demo.modules.mq.rabbit.service.dead;

import com.demo.modules.mq.rabbit.RabbitAnnouncementMessage;
import com.demo.modules.mq.rabbit.configuration.DeadConfiguration;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 消息生产者
 *
 * @author Rog
 */
@Slf4j
@Component
public class RabbitDeadMessageProducerService {

    @Autowired
    private RabbitTemplate rabbitTemplate;


    public void sendMessage() {
        for (int i = 0; i < 6; i++) {
            RabbitAnnouncementMessage rabbitAnnouncementMessage = new RabbitAnnouncementMessage();
            rabbitAnnouncementMessage.setId("2");
            rabbitAnnouncementMessage.setContent("这是一条测试消息" + i);
            rabbitTemplate.convertAndSend(DeadConfiguration.FORMAL_EXCHANGE,DeadConfiguration.FORMAL_ROUNTE_KEY,rabbitAnnouncementMessage);
        }
    }
}

